<template>
	<view>
		
		<view class="topList">
			<view class="list" v-for="item in list" :key="item.id">
				<image :src="item.advert_pic" mode="widthFix"></image>
				<view class="top">
					<text>{{item.name}}</text>
					<text>{{item.subtitle}}</text>
				</view>
				<view class="listBody">
					<view class="item" v-for="ite in item.child" :key="ite.id" @click="navTo(ite)">
						<image :src="ite.pic_url?ite.pic_url:'../../static/image/icon/loading-img.png'"></image>
						<text>{{ite.name}}</text>
						<text>{{ite.subtitle}}</text>
						<image @click.stop="router(ite)" src="https://hj.qfxwl.com/web/statics/img/admin/index_05.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
	    name: "app-map",
		data(){
			return{
				list:[]
			}
		},
		methods:{
			getList(){
				this.$request({url:this.$api.default.cat_list}).then(res=>{
					if(res.code==0){
						this.list = res.data.list
					}
				})
			},
			router(item){
				if(item.vr_url==''){
					uni.showToast({
						title: '无全景图',
						icon:'none'
					});
					return
				}
				
				uni.navigateTo({
					url:"/pages/web/web?url="+encodeURIComponent(item.vr_url),
					fail:(res)=>{
						console.log(res);
					}
				})
			},
			navTo(item){
				uni.navigateTo({
					url:item.page_url
				})
			}
		},
		created() {
			this.getList()
		}
	}
</script>

<style scoped lang="scss">
.list{
	background-color: #fff;
	>image{
		width: 100%;
		display: block;
	}
	.top{
		background-image: url('https://hj.qfxwl.com/web/statics/img/admin/index_02.png');
		height: 149.25upx;
		background-size: contain;
		background-repeat: no-repeat;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		font-weight: bold;
		color: #ccc;
		text:nth-child(1){
			font-size: 1.5em;
			color: #000;
		}
		text:nth-child(2){
			font-size:0.8em;
		}
	}
	.listBody{
		display: flex;
		align-items: flex-start;
		flex-wrap: wrap;
		padding: 0 0%;
		.item{
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 25%;
			margin: 4.166%;
			justify-content: space-between;
			height: 400upx;
			text-align: center;
			image:nth-child(1){
				width: 100%;
				height: 169upx;
				display: block;
				border-radius: 10upx;
				margin-bottom: 10upx;
			}
			text:nth-child(2){
				font-weight: bold;
				font-size: 0.9em;
				text-align: center;
			}
			text:nth-child(3){
				color: #999;
				font-size: 0.8em;
				text-align: center;
				margin-top: -5upx;
			}
			image:nth-child(4){
				width: 100%;
				display: block;
			}
		}
	}
}
</style>
